﻿#include "includes\\InputStructures.fx"
#include "includes\\CommonResources.fx"
#include "includes\\StateDefinitions.fx"
#include "includes\\BlinnShading.fx"

float4x4 xBikeTranslationMatrix;
float4x4 xBikeRotationMatrix;
texture2D xBikeTexture;


struct PsInput_Bike
{
	float4 ScreenPos : SV_POSITION;
	float3 Pos3D : POSITION;
	float2 UV: TEXCOORD;
	float3 Normal : NORMAL;
};


PsInput_Bike BikeVS(VsInput_PTN input)
{
	PsInput_Bike output = (PsInput_Bike)0;
	
	float4x4 transformationMatrix = mul(xBikeRotationMatrix, xBikeTranslationMatrix);
	float4x4 wvpMatrix = mul(transformationMatrix, xViewProjectionMatrix);
	output.ScreenPos = mul(input.Pos, wvpMatrix);
	output.Pos3D = mul(input.Pos, transformationMatrix).xyz;
	output.UV = input.UV;
	output.Normal = normalize(mul(input.Normal, xBikeRotationMatrix).xyz);
	
	return output;
}


float4 BikePS(PsInput_Bike input) : SV_Target
{
	float3 sampledColor = xBikeTexture.Sample(PlanarSampler, input.UV).rgb;
	float3 bikeColor = float3(xPlayerColor.rgb * sampledColor.rgb);

	float3 result = GetBlinnShadedColor(bikeColor, input.Pos3D, input.Normal, cGlobalLightPosition, 32.0f, 1.0f, 0.5f);
	return float4(result.rgb, 1.0f);
}

float4 BikePS_NoTex(PsInput_Bike input) : SV_Target
{
	float3 sampledColor = float3(0.5f, 0.5f, 0.5f);
	float3 bikeColor = float3(xPlayerColor.rgb * sampledColor.rgb);

	float3 result = GetBlinnShadedColor(bikeColor, input.Pos3D, input.Normal, cGlobalLightPosition, 32.0f, 1.0f, 0.5f);
	return float4(result.rgb, 1.0f);
}
